/* eslint valid-jsdoc: "off" */

"use strict";

const path = require("path");

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
    /**
     * built-in config
     * @type {Egg.EggAppConfig}
     **/
    const config = exports = {};

    // use for cookie sign key, should change to your own and keep security
    config.keys = `${appInfo.name}_QQ_748943649`;

    // add your middleware config here
    config.middleware = [
        "exceptions",
        "verifyLogin", // 验证登录
    ];

    // 静态资源配置
    // https://github.com/eggjs/egg-static
    config.static = {
        dir: [
            { prefix: "/apidoc", dir: path.join(appInfo.baseDir, "app/public/apidoc/") }, // apidoc
        ],
        dynamic: true,
        preload: false,
    };

    config.cors = {
        origin: "*",
        allowMethods: "GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS",
    };

    config.security = {
        csrf: false,
    };

    // add your user config here
    const userConfig = {
        // myAppName: 'egg',
    };

    return {
        ...config,
        ...userConfig,
    };
};
